package com.eastfair.tag.enumeration;

import com.eastfair.annotation.base.BaseEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.stream.Stream;

/**
 * 资源类型枚举类
 *
 * @ClassName ResourceTypeEnum
 * @Author zjn
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "ResourceTypeEnum", description = "资源类型")
public enum TagResourceTypeEnum implements BaseEnum {

    /**
     * 默认，直接挂接
     */
    DEFAULT("默认，直接挂接"),

    /**
     * 问卷答案
     */
    QUESTION_ANSWER("问卷答案"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static TagResourceTypeEnum match(String val, TagResourceTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static TagResourceTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(TagResourceTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "资源类型", allowableValues = "ACTOR", example = "ACTOR")
    public String getCode() {
        return this.name();
    }
}
